﻿Imports Business
Public Class frmFPTerminalDetail
    Dim machineNo1 As Integer
    Dim groupID1 As Integer
    Dim lisence As Integer = 1261
    Dim dataCurrentRow As DataGridViewRow
    Dim fnCommHandleIndex As Long

    Public strServer As String

    Public Sub New(ByVal dataGrdRow As DataGridViewRow, ByVal groupID As Integer, ByVal serverName As String)
        ' This call is required by the designer.
        InitializeComponent()
        groupID1 = groupID
        strServer = serverName
        'machineNo1 = dataCurrentRow.Item(0)
        ' Add any initialization after the InitializeComponent() call.
        If dataGrdRow Is Nothing Then
            machineNo1 = 0
            LoadNew()
        Else
            machineNo1 = dataGrdRow.Cells.Item(0).Value
            dataCurrentRow = dataGrdRow
            LoadDetail()
        End If
    End Sub

#Region "Event Select Alarm"
    '/******************************************************************/
    '/*                         Event Select Alarm                     */
    '/******************************************************************/   
    Private Sub btnSelectAlarm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectAlarm.Click
        If (nudAlarmNo.Value <> 0) Then

            If CheckAlarmNo(nudAlarmNo.Value) = True Then
                If CheckAlarmTime(mtxtAlarmTime.Text) = True Then
                    If ValidateTime(mtxtAlarmTime.Text) = True Then
                        lstAlarm.Items.Add("Alarm " & nudAlarmNo.Value & " : " & mtxtAlarmTime.Text)
                        mtxtAlarmTime.BackColor = Color.White
                        nudAlarmNo.BackColor = Color.White
                        Message("")
                        lstAlarm.Show()
                    Else
                        mtxtAlarmTime.BackColor = Color.Pink
                        Message("Alarm Time is not valid")
                    End If

                Else
                    mtxtAlarmTime.BackColor = Color.Pink
                    Message("Alarm Time is existed")
                End If
            Else
                nudAlarmNo.BackColor = Color.Pink
                Message("Alarm No is existed")
            End If
        End If
    End Sub
#End Region

#Region "Event Delete Alarm from list box Alarm"
    '/******************************************************************/
    '/                      Su kien delete Alarm                       */
    '/******************************************************************/ 
    Private Sub btnDeleteAlarm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeleteAlarm.Click
        If lstAlarm.SelectedItem Is Nothing Then
            Message("Please choose Alarm")
        Else
            lstAlarm.Items.Remove(lstAlarm.SelectedItem)
            lstAlarm.Show()
            Message("")
        End If
    End Sub
#End Region

#Region "Sub Load New Form & Load Detail Form"
    '/******************************************************************/
    '/*                        Load Form New                           */
    '/******************************************************************/  
    Public Sub LoadNew()
        'Load combobox Group
        Dim bsGroup As New BSGroup(strServer)
        cboGroup.DataSource = bsGroup.GetAllGroup()
        cboGroup.DisplayMember = "GROUP_NAME"
        cboGroup.ValueMember = "GROUP_ID"
        cboGroup.SelectedValue = groupID1
        'Load Device
        Dim bsTerminalSetting As New BSTerminalSetting(strServer)
        cboDevice.Items.Add(DEVICENAME_TCPIP)
        cboDevice.Items.Add(DEVICENAME_USB)
        cboDevice.SelectedIndex = DEVICE_TCPIP
        'Default Usage Type
        rdoBothOnOffDuty.Checked = True
    End Sub

    '/******************************************************************/
    '/*                        Load Detail                             */
    '/******************************************************************/
    Public Sub LoadDetail()
        'Load group
        Dim bsGroup As New BSGroup(strServer)
        cboGroup.DataSource = bsGroup.GetAllGroup()
        cboGroup.DisplayMember = "GROUP_NAME"
        cboGroup.ValueMember = "GROUP_ID"
        cboGroup.SelectedValue = groupID1
        'Load Terminal Information
        'Load Device
        Dim bsTerminalSetting As New BSTerminalSetting(strServer)
        cboDevice.Items.Add(DEVICENAME_TCPIP)
        cboDevice.Items.Add(DEVICENAME_USB)
        cboDevice.SelectedIndex = bsTerminalSetting.GetDeviceID(dataCurrentRow.Cells.Item(2).Value)
        'Load MachineNo
        txtMachineNo.Text = dataCurrentRow.Cells.Item(0).Value
        'Load IPAddress
        txtIPAddress.Text = dataCurrentRow.Cells.Item(3).Value
        'Load Port
        txtPort.Text = dataCurrentRow.Cells.Item(4).Value
        'Load Use Type
        Select Case bsTerminalSetting.GetUseTypeID(dataCurrentRow.Cells.Item(1).Value)
            Case USETYPE_ONLYUSERREGISTRATION
                rdoOnlyUseRegistration.Checked = True
            Case USETYPE_ONLYONDUTY
                rdoOnlyOnDuty.Checked = True
            Case USETYPE_ONLYOFFDUTY
                rdoOnlyOffDuty.Checked = True
            Case USETYPE_BOTHONOFFDUTY
                rdoBothOnOffDuty.Checked = True
            Case Else
                rdoAll.Checked = True
        End Select
        'Load Alarm time of Machine
        Dim bsAlarm As New BSAlarm(strServer)
        For i As Integer = 0 To bsAlarm.GetAlarm(machineNo1).Rows.Count - 1
            Dim arrayAlarmTime() As String = {bsAlarm.GetAlarm(machineNo1).Rows(i).Item(2).ToString().Substring(0, 2),
                                              bsAlarm.GetAlarm(machineNo1).Rows(i).Item(2).ToString().Substring(2, 2)}
            lstAlarm.Items.Add("Alarm " & bsAlarm.GetAlarm(machineNo1).Rows(i).Item(1) & " : " & arrayAlarmTime(0) & ":" & arrayAlarmTime(1))
        Next
    End Sub
#End Region

#Region "Select combobox Device Name"
    '/******************************************************************/
    '/                      Select Device Name                         */
    '/******************************************************************/
    Private Sub cboDevice_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboDevice.SelectedIndexChanged
        If cboDevice.SelectedIndex = 0 Then
            EnableDeviceOption(True)
        Else
            EnableDeviceOption(False)
        End If
    End Sub

    '/******************************************************************/
    '/                  Function Enable Device option                  */
    '/******************************************************************/ 
    Public Sub EnableDeviceOption(ByVal chk As Boolean)
        If chk = True Then
            txtIPAddress.Clear()
            txtPort.Clear()
            txtIPAddress.Enabled = True
            txtPort.Enabled = True
        Else
            txtIPAddress.Clear()
            txtPort.Clear()
            txtIPAddress.Enabled = False
            txtPort.Enabled = False
        End If
    End Sub
#End Region

#Region "Event Registry FP terminal"
    '/******************************************************************/
    '/                   Su kien registry FP terminal                  */
    '/******************************************************************/ 
    Private Sub btnRegistry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRegistry.Click
        If machineNo1 = 0 Then
            If txtMachineNo.Text <> "" Then
                If checktxtMachineNo(CInt(txtMachineNo.Text)) = False Then
                    If cboDevice.SelectedIndex = 0 Then
                        If txtIPAddress.Text <> "" And txtIPAddress.BackColor <> Color.Pink Then
                            If txtPort.Text <> "" Then
                                If CheckConnect(DEVICE_TCPIP, CInt(txtMachineNo.Text), txtIPAddress.Text, CInt(txtPort.Text), 5000, False, 2, lisence) Then
                                    Insert()
                                Else
                                    Message("Please check a FP Terminal (Machine No, IP, Port,...)")
                                End If
                            Else
                                Message("Please input Port")
                            End If
                        Else
                            Message("IP Address is wrong")
                        End If
                    Else
                        If CheckConnect(DEVICE_USB, CInt(txtMachineNo.Text), Nothing, Nothing, Nothing, Nothing, Nothing, lisence) Then
                            Insert()
                        Else
                            Message("Please check USB port")
                        End If
                    End If
                Else
                        Message("Machine No is existed")
                End If
            Else
                Message("Please input Machine No")
            End If
        Else

            Modify()

        End If
    End Sub
#End Region

#Region "Sub insert new terminal"
    '/******************************************************************/
    '/                  Function Insert new Terminal                   */
    '/******************************************************************/
    Public Sub Insert()
        'Get value of rdoUseType
        Dim useTypeValue As Integer
        If rdoOnlyUseRegistration.Checked Then useTypeValue = USETYPE_ONLYUSERREGISTRATION
        If rdoOnlyOnDuty.Checked Then useTypeValue = USETYPE_ONLYONDUTY
        If rdoOnlyOffDuty.Checked Then useTypeValue = USETYPE_ONLYOFFDUTY
        If rdoBothOnOffDuty.Checked Then useTypeValue = USETYPE_BOTHONOFFDUTY
        If rdoAll.Checked Then useTypeValue = USETYPE_ALL

        If CheckUseType(useTypeValue) = False Then

            'Insert Alarm of terminal setting

           


            'Insert data terminal setting
            Dim bsTerminalSetting As New BSTerminalSetting(strServer)
            Dim bsFKAttend As New BSFKAttend(strServer)
            If cboDevice.SelectedIndex = 1 Then
                bsTerminalSetting.InsertTerminalSetting(CInt(txtMachineNo.Text), DirectCast(cboGroup.SelectedItem, DataRowView).Item("GROUP_ID"),
            useTypeValue, 1, 0,
            0, 1, Date.Now, Date.Now)
                Message("Insert is successfull")
            Else
                If CheckIPAddress(txtIPAddress.Text) = False Then
                    bsTerminalSetting.InsertTerminalSetting(CInt(txtMachineNo.Text), DirectCast(cboGroup.SelectedItem, DataRowView).Item("GROUP_ID"),
                useTypeValue, cboDevice.SelectedIndex, txtIPAddress.Text,
                CInt(txtPort.Text), 1, Date.Now, Date.Now)
                    Message("Insert is successfull")
                Else
                    Message("IP Address is existed")
                End If
            End If

            If lstAlarm IsNot Nothing Then
                Dim bsAlarm As New BSAlarm(strServer)
                Dim bsFKAttend1 As New BSFKAttend(strServer)
                For i As Integer = 0 To lstAlarm.Items.Count - 1
                    Dim alarmNo As Integer = CInt(lstAlarm.Items(i).ToString().Split(" ")(1))
                    Dim arrayAlarmTime() As String = lstAlarm.Items(i).ToString().Split(" ")(3).Split(":")
                    Dim alarmTime As Integer = CInt(arrayAlarmTime(0) & arrayAlarmTime(1))
                    bsAlarm.InsertAlarm(CInt(txtMachineNo.Text), alarmNo, alarmTime, Date.Now, Date.Now)
                    bsFKAttend1.SetAlarm(CInt(txtMachineNo.Text), txtIPAddress.Text, CInt(txtPort.Text), 5000, False, 2, 1261, cboDevice.SelectedIndex, alarmNo, alarmTime)
                Next
            End If


        Else
            Message("Only choose one FPTerminal for registration")
        End If
    End Sub
#End Region

#Region "Sub modify terminal"
    '/******************************************************************/
    '/                  Function Modify new Terminal                   */
    '/******************************************************************/
    Public Sub Modify()
        Dim bsTerminalSetting As New BSTerminalSetting(strServer)
        Dim bsAlarm As New BSAlarm(strServer)

        If CInt(txtMachineNo.Text) <> machineNo1 Then
            If MessageBox.Show("Confirm", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) = DialogResult.OK Then
                'Insert new record
                Message("Working!")
                Application.DoEvents()
                Insert()
                'Delete last record
                bsTerminalSetting.DeleteTerminalSetting(machineNo1)
                bsAlarm.DeleteAlarm(machineNo1)
                Message("Modify is successfull")
                Application.DoEvents()
            End If
        Else
            'Update record
            Message("Working!")
            Application.DoEvents()

            'Get value of rdoUseType
            Dim useTypeValue As Integer
            If rdoOnlyUseRegistration.Checked Then useTypeValue = USETYPE_ONLYUSERREGISTRATION
            If rdoOnlyOnDuty.Checked Then useTypeValue = USETYPE_ONLYONDUTY
            If rdoOnlyOffDuty.Checked Then useTypeValue = USETYPE_ONLYOFFDUTY
            If rdoBothOnOffDuty.Checked Then useTypeValue = USETYPE_BOTHONOFFDUTY
            If rdoAll.Checked Then useTypeValue = USETYPE_ALL

            If CheckUseType(useTypeValue) = False Then
                'Update Alarm of Terminal Setting
                bsAlarm.DeleteAlarm(machineNo1)
                Dim bsFKAttend1 As New BSFKAttend(strServer)
                For i As Integer = 0 To lstAlarm.Items.Count - 1
                    Dim alarmNo As Integer = CInt(lstAlarm.Items(i).ToString().Split(" ")(1))
                    Dim arrayAlarmTime() As String = lstAlarm.Items(i).ToString().Split(" ")(3).Split(":")
                    Dim alarmTime As Integer = CInt(arrayAlarmTime(0) & arrayAlarmTime(1))
                    bsAlarm.InsertAlarm(CInt(machineNo1), alarmNo, alarmTime, Date.Now, Date.Now)
                    bsFKAttend1.SetAlarm(CInt(machineNo1), txtIPAddress.Text, CInt(txtPort.Text), 5000, False, 2, 1261, cboDevice.SelectedIndex, alarmNo, alarmTime)
                Next

                'Update Terminal Setting

                If cboDevice.SelectedIndex = 1 Then
                    bsTerminalSetting.UpdateTerminalSetting(CInt(txtMachineNo.Text), DirectCast(cboGroup.SelectedItem, DataRowView).Item("GROUP_ID"),
                                                            useTypeValue, 1, 0, 0, Date.Now)
                    Message("Modify is successfull")
                Else
                    'If CheckIPAddress(txtIPAddress.Text) = False Then
                    bsTerminalSetting.UpdateTerminalSetting(CInt(txtMachineNo.Text), DirectCast(cboGroup.SelectedItem, DataRowView).Item("GROUP_ID"),
                    useTypeValue, cboDevice.SelectedIndex, txtIPAddress.Text,
                    CInt(txtPort.Text), Date.Now)
                    Message("Modify is successfull")
                    'Else
                    'Message("IP Address is existed")
                    'End If
                End If
            Application.DoEvents()
            Else
            Message("Only choose one FPTerminal for registration")
        End If
        End If
    End Sub
#End Region

#Region "Valid input data"
    '/******************************************************************/
    '/                      Valid txt IP Address                       */
    '/******************************************************************/
    Private Sub txtIPAddress_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtIPAddress.Leave
        Try
            Dim bsTerminalSetting As New BSTerminalSetting(strServer)
            If bsTerminalSetting.CheckIPConnect(txtIPAddress.Text) = "Disconnect" Then
                txtIPAddress.BackColor = Color.Pink
                Message("No Connection or IP Address is not valid")
            Else
                txtIPAddress.BackColor = Color.White
            End If
        Catch
            txtIPAddress.BackColor = Color.Pink
            Message("No Connection or IP Address is not valid")
        End Try
    End Sub

    '/******************************************************************/
    '/                      validating txtPort                         */
    '/******************************************************************/ 
    Private Sub txtPort_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPort.Leave
        If txtPort.Text = "" Then
            txtPort.BackColor = Color.Pink
            Message("Please input Port")
        Else
            txtPort.BackColor = Color.White
        End If
    End Sub

    '/******************************************************************/
    '/*                           Check txtMachiNo                     */
    '/******************************************************************/  
    Public Function checktxtMachineNo(ByVal machineNo As Integer) As Boolean
        Dim bsTerminalSetting As New BSTerminalSetting(strServer)
        Dim dt As DataTable = bsTerminalSetting.GetAllTerminalSetting()
        For i As Integer = 0 To dt.Rows.Count - 1
            If machineNo = dt.Rows(i).Item(0) Then
                Return True
            End If
        Next
        Return False
    End Function


    '/******************************************************************/
    '/*                        Validate txtPort                        */
    '/******************************************************************/  
    Private Sub txtPort_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtPort.KeyPress
        Dim txtCell As TextBox = sender
        txtCell.MaxLength = 4
        If (Char.IsDigit(e.KeyChar) Or Char.IsControl(e.KeyChar)) Then
            e.Handled = False
        Else
            e.Handled = True
        End If
    End Sub

    '/******************************************************************/
    '/*                        Validate txtMachiNo                     */
    '/******************************************************************/  
    Private Sub txtMachineNo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtMachineNo.KeyPress
        Dim txtCell As TextBox = sender
        txtCell.MaxLength = 4
        If (Char.IsDigit(e.KeyChar) Or Char.IsControl(e.KeyChar)) Then
            e.Handled = False
        Else
            e.Handled = True
        End If
    End Sub

    '/******************************************************************/
    '/*                        Fuction check AlarmTime                 */
    '/******************************************************************/   
    Public Function CheckAlarmTime(ByVal alarmTime As String) As Boolean
        If lstAlarm Is Nothing Then
            Return True
        Else
            For i As Integer = 0 To lstAlarm.Items.Count - 1
                Dim strAlarmTime As String = lstAlarm.Items(i).ToString().Split(" ")(3)
                If alarmTime = strAlarmTime Then
                    Return False
                End If
            Next
            Return True
        End If
    End Function

    '/******************************************************************/
    '/*                        Fuction check AlarmNo                   */
    '/******************************************************************/   
    Public Function CheckAlarmNo(ByVal alarmNo As Integer) As Boolean
        If lstAlarm Is Nothing Then
            Return True
        Else
            For i As Integer = 0 To lstAlarm.Items.Count - 1
                Dim strAlarmNo As String = lstAlarm.Items(i).ToString().Split(" ")(1)
                If alarmNo = strAlarmNo Then
                    Return False
                End If
            Next
            Return True
        End If
    End Function

    '/******************************************************************/
    '/*                             Validate Time                      */
    '/******************************************************************/   
    Private Function ValidateTime(ByVal alarmTime As String) As Boolean
        Try
            Dim array() As String
            array = alarmTime.Split(":")
            If IsNumeric(array(0)) And IsNumeric(array(1)) And CInt(array(0)) >= 0 And CInt(array(0)) <= 23 And CInt(array(1)) >= 0 And CInt(array(1)) <= 59 Then
                Return True
            Else
                Return False
            End If
        Catch
            Return False
        End Try
    End Function

    '/******************************************************************/
    '/                      validating txtMachineNo                    */
    '/******************************************************************/ 

    Private Sub txtMachineNo_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtMachineNo.Leave
        If txtMachineNo.Text = "" Then
            txtMachineNo.BackColor = Color.Pink
            Message("Please input Machine No")
        Else
            If checktxtMachineNo(txtMachineNo.Text) = True Then
                txtMachineNo.BackColor = Color.Pink
                Message("Machine No is existed")
            Else
                txtMachineNo.BackColor = Color.White
            End If
        End If
    End Sub


    '/******************************************************************/
    '/                      Check use type only one                    */
    '/******************************************************************/

    Public Function CheckUseType(ByVal usetypeID As Integer) As Boolean
        Dim bsTerminalSetting As New BSTerminalSetting(strServer)
        Dim dt As DataTable = bsTerminalSetting.GetAllTerminalSetting()
        If usetypeID = USETYPE_ONLYUSERREGISTRATION Or usetypeID = USETYPE_ALL Then
            For i As Integer = 0 To dt.Rows.Count - 1
                If CInt(dt.Rows(i).Item(2)) = USETYPE_ONLYUSERREGISTRATION Or CInt(dt.Rows(i).Item(2)) = USETYPE_ALL Then
                    Return True
                End If
            Next
        End If
        Return False
    End Function

    '/******************************************************************/
    '/                      Check IP Address only one                  */
    '/******************************************************************/

    Public Function CheckIPAddress(ByVal ipAddress As String) As Boolean
        Dim bsTerminalSetting As New BSTerminalSetting(strServer)
        Dim dt As DataTable = bsTerminalSetting.GetAllTerminalSetting()
            For i As Integer = 0 To dt.Rows.Count - 1
            If dt.Rows(i).Item(4).ToString() = txtIPAddress.Text Then
                Return True
            End If
            Next
        Return False
    End Function


    '/******************************************************************/
    '/*                           Check Connect                        */
    '/******************************************************************/
    'Return True when check connect is successfull

    Public Function CheckConnect(ByVal deviceNo As Integer, ByVal machineNo As Integer, ByVal ipAddress As String,
                                        ByVal port As Integer,
                                        ByVal timeOut As Integer,
                                    ByVal chkUDP As Boolean,
                                    ByVal password As Integer,
                                    ByVal lisence As Integer) As Boolean
        Message("Checking to FP Terminal")
        Application.DoEvents()
        Dim bsFKAttend As New BSFKAttend(strServer)
        Dim vnResultCode As Integer
        'Connect to FP terminal
        If deviceNo = DEVICE_USB Then
            fnCommHandleIndex = bsFKAttend.CheckConnectUSB(machineNo, lisence)
        Else
            fnCommHandleIndex = bsFKAttend.CheckConnectNet(machineNo, ipAddress, port, timeOut, chkUDP, password, lisence)
        End If
        If fnCommHandleIndex > 0 Then
            Return True
        Else
            Return False
        End If
        Application.DoEvents()
    End Function


    ''/******************************************************************/
    ''/             Leave mtxtIPAddress with valid & check connect      */
    ''/******************************************************************/  
    'Private Sub mtxtIPAdress_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs)
    '    Try
    '        Dim bsTerminalSetting As New BSTerminalSetting(strServer)
    '        If ValidateIPAddress() = False Or bsTerminalSetting.CheckIPConnect(mtxtIPAdress.Text.Replace(",", ".")) = "Disconnect" Then
    '            mtxtIPAdress.BackColor = Color.Pink
    '            Message("No Connection or IP Address is not valid")
    '            e.Cancel = True
    '        Else
    '            mtxtIPAdress.BackColor = Color.White
    '        End If
    '    Catch
    '        mtxtIPAdress.BackColor = Color.Pink
    '        Message("No Connection or IP Address is not valid")
    '        e.Cancel = True
    '    End Try
    'End Sub

    ''/******************************************************************/
    ''/*                        Validate IPAddress                      */
    ''/******************************************************************/   
    'Private Function ValidateIPAddress() As Boolean
    '    Try
    '        Dim ipAddress As String = txtIPAdress.Text
    '        Dim array() As String
    '        array = ipAddress.Split(",")
    '        If IsNumeric(array(0)) And IsNumeric(array(1)) And IsNumeric(array(2)) And IsNumeric(array(3)) And CInt(array(0)) > 0 And CInt(array(0)) <= 255 And CInt(array(1)) >= 0 And CInt(array(1)) <= 255 And CInt(array(2)) >= 0 And CInt(array(2)) <= 255 And CInt(array(3)) >= 0 And CInt(array(3)) <= 255 Then
    '            Return True
    '        Else
    '            Return False
    '        End If
    '    Catch
    '        Return False
    '    End Try
    'End Function
#End Region

#Region "Show Message"
    '/******************************************************************/
    '/                           Group Message                         */
    '/******************************************************************/ 
    Public Sub Message(ByVal strMessage As String)
        lblMessage.Text = strMessage
    End Sub
#End Region

#Region "Event Cancel Form"
    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        frmMain.RemoveTabpage()
        Dim bsFKAttend As New BSFKAttend(strServer)
        bsFKAttend.Disconnect(fnCommHandleIndex)
    End Sub
#End Region

    'Private Sub cboGroup_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboGroup.SelectedIndexChanged
    '    If DirectCast(cboGroup.SelectedItem, DataRowView).Item("GROUP_ID") = 1290 Then
    '        Dim frmGm As New frmGroupManager
    '        frmGm.ShowDialog()
    '        'MsgBox("penis")
    '    End If
    'End Sub
End Class